import 'package:app/common/colors.dart';
import 'package:app/common/tool.dart';
import 'package:app/components/base_scaffold_appbar.dart';
import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../common/app_theme.dart';
import 'my_calendar_detail_controller.dart';

class MyCalendarDetailView extends GetView{


  MyCalendarDetailController controller = Get.put(MyCalendarDetailController());
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      backgroundColor: AppColor.bgColor,
      appBar: BaseAppBar(
        preferredSize: Size(Get.width, AppTool.appBarHEIGHT),
        child: const Text('日程详情'),
      ),
      body:GetBuilder<MyCalendarDetailController>(builder: (_){
        return  ListView(
          padding: EdgeInsets.all(0),
          children: [

            Container(
                padding: EdgeInsets.only(left: 15,right: 15),
                color: Colors.white,
                // alignment: Alignment.centerRight,
                // height: 40,

                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('日程名称',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Container(
                      // color: Colors.yellow,
                      width: 180,
                      alignment: Alignment.centerRight,
                      padding: EdgeInsets.only(top: 15,bottom: 15),
                      // constraints: BoxConstraints(
                      //     minHeight: 40,
                      //     maxHeight: 120
                      // ),
                      // height: 30,
                      child: Text('${controller.model?.data?.name??''}',maxLines: 3,),
                    )
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),
            Container(
                padding: EdgeInsets.only(left: 15,right: 15),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                height: 40,
                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('开始时间',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Text('${controller.model?.data?.startTime??''}'),
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),
            Container(
                padding: EdgeInsets.only(left: 15,right: 15),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                height: 40,
                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('结束时间',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Text('${controller.model?.data?.endTime??''}'),
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),
            Container(
                padding: EdgeInsets.only(left: 15,right: 15),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                height: 40,
                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('是否整天',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Text('${controller.model?.data?.allDay==true?'是':'否'}')
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),
            Container(
                padding: EdgeInsets.only(left: 15,right: 15),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                height: 40,
                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('持续时间',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Text('${controller.model?.data?.duration}分钟'),
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),
            Container(
                padding: EdgeInsets.only(left: 15,right: 15),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                height: 40,
                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('公开程度',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Text('${controller.model?.data?.privacy}'),
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),

            Container(
                padding: EdgeInsets.only(left: 15,right: 15),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                height: 40,
                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('描述',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Text('${controller.model?.data?.description??'暂无'}')
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),

            Container(
                padding: EdgeInsets.only(left: 15,right: 15),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                height: 40,
                child:  Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('位置',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Text('${controller.model?.data?.location??''}')
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),
            Container(
                padding: EdgeInsets.only(left: 15,right: 0),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                // height: 100,
                child:  Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text('参与人名',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Wrap(
                      children: userNameBody(),
                    )
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),

            Container(
                padding: EdgeInsets.only(left: 15,right: 0),
                color: Colors.white,
                alignment: Alignment.centerLeft,
                // height: 100,
                child:  Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text('分享人名',style: appThemeData.textTheme.subtitle1!.copyWith(fontSize: 15),),
                    Wrap(
                      children: shardUserNameBody(),
                    )
                  ],
                )
            ),
            SizedBox(
              height: 1,
            ),

          ],
        );
      }),
    );
  }
  List<Widget> userNameBody(){
    List<Widget> body = [];
    for(int i = 0;i<controller.model!.data!.shareUserNames!.length;i++){
      body.add(Container(
        margin: EdgeInsets.only(left: 4),
        child: FilterChip(
          backgroundColor: AppColor.bgColor,
          label: Text('${controller.model!.data!.shareUserNames![i]}'),
          onSelected: (bool value) {  },
        ),
      ));
    }
    return body;
  }

  List<Widget> shardUserNameBody(){
    List<Widget> body = [];
    for(int i = 0;i<controller.model!.data!.userNames!.length;i++){
      body.add(Container(
        margin: EdgeInsets.only(left: 4),
        child: FilterChip(
          backgroundColor: AppColor.bgColor,
          label: Text('${controller.model!.data!.userNames![i]}'),
          onSelected: (bool value) {  },
        ),
      ));
    }
    return body;
  }

}